﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.WindowsAzure.MobileServices;
using Windows.Devices.Geolocation;
using Microsoft.Phone.Notification;

namespace Geo_Meet
{
    public partial class Createchat : PhoneApplicationPage
    {
        public Createchat()
        {
            InitializeComponent();
        }



        private async void createGroup_Click(object sender, RoutedEventArgs e)
        {
            chatGroups chatgroups = new chatGroups();
            if (!string.IsNullOrWhiteSpace(name.Text) || !string.IsNullOrWhiteSpace(limit.Text))
            {
                chatgroups.Name = name.Text;
                chatgroups.limit = int.Parse(limit.Text);
                //Name = name.Text;
            }
            //chatgroups.CurrentChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            Geolocator geolocator = new Geolocator();
            geolocator.DesiredAccuracyInMeters = 50;

            try
            {
                Geoposition geoposition = await geolocator.GetGeopositionAsync();
                chatgroups.latitudE = geoposition.Coordinate.Latitude;
                chatgroups.longitudE = geoposition.Coordinate.Longitude;

                await App.MobileService.GetTable<chatGroups>().InsertAsync(chatgroups);
                NavigationService.Navigate(new Uri("/Chat.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
            }
        }
    }
}